<template>
  <router-link :to="{name:'positionDetail',query:{id:data.id,jobType:data.jobType}}"  class="position-item">
    <div class="info-block">
      <div class="info">
        <div class="info-item">
          <div class="position-name">{{data.jobTitle}}</div>
          <div v-if="data.salaryNegotiable==1" class="wage">面议</div>
          <div v-else class="wage">{{data.minSalary }}-{{ data.maxSalary}}元</div>
        </div>
        <div class="address-item">
          <div class="position-address"><i class="el-icon-location-outline"></i> {{data.jobAddress }}</div>
          <div class="position-label-block" v-if="data.comRecruiters.enterprise.welfareList&&data.comRecruiters.enterprise.welfareList.length>0">
            <div class="position-label-item" v-for="(item1) in data.comRecruiters.enterprise.welfareList">
              <div v-if="item1!=='null'">{{ item1 }}</div>
              <div v-else>面议</div>
            </div>
          </div>
          <div class="position-label-block" v-else>
            <div class="position-label-item">面议</div>
          </div>
        </div>
      </div>
    </div>
    <div class="company-block">
      <div class="company-photo">
        <img :src="data.comRecruiters.enterprise.logoUrl" alt="" @error="imgError">
      </div>
      <div class="company-info">
        <div class="company-name">{{ data.comRecruiters.enterprise.enterpriseName }}</div>
        <div class="company-other">{{ data.comRecruiters.enterprise.enterpriseTypeText }} / {{ data.comRecruiters.enterprise.scaleName }}</div>
      </div>
    </div>
  </router-link>
</template>

<script>
export default {
  name: "PositionItem",
  props: {
    data: Object
  },
  methods:{
    imgError(){
      this.data.comRecruiters.enterprise.logoUrl = process.env.VUE_APP_COM_URL;
    },
  }
}
</script>

<style lang="scss" scoped>
.position-item {
  width: 100%;
  padding: 20px;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 5px;
  cursor: pointer;
  .info-block {
    border-bottom: 1px solid $lightGray;
    display: flex;
    flex-direction: row;
    height: 60%;

    .info {
      width: 100%;
      display: flex;
      flex-direction: row;
      flex-wrap: wrap;
      .info-item{
        display: flex;
        flex-direction: row;
        .position-name {
          font-size: 19px;
          width: 220px;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
        .wage {
          width: 180px;
          color: $orange;
          font-weight: bold;
          font-size: 17px;
          display: flex;
          flex-direction: row;
          flex-grow: 1;
        }
      }
      .address-item{
        display: flex;
        flex-direction: column;
        width: 100%;
        .position-address {
          width: 100%;
          font-size: 12px;
          color: $darkGray;
          margin: 15px 10px 15px 0;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }

        .position-label-block {
          display: flex;
          flex-direction: row;
          flex-wrap: wrap;
          margin-bottom: 10px;

          .position-label-item {
            margin-right: 10px;
            margin-bottom: 10px;
            height: 25px;
            color: $darkGray;
            background: $lightGray;
            padding: 4px 8px;
            font-size: 13px;
          }
        }
      }

    }
  }

  .company-block {
    display: flex;
    flex-direction: row;
    padding-top: 15px;
    align-items: center;

    .company-photo {
      width: 50px;
      height: 50px;
      border: 1px solid $lightGray;
      margin-right: 15px;

      img {
        width: 100%;
        height: 100%;
      }
    }

    .company-info {
      width: calc(100% - 65px);
      display: flex;
      flex-direction: column;
      justify-content: center;

      .company-name {
        font-size: 15px;
      }

      .company-other {
        overflow:hidden;
        text-overflow:ellipsis;
        display:-webkit-box;
        -webkit-box-orient:vertical;
        -webkit-line-clamp:2;
        font-size: 12px;
        color: $darkGray;
        margin-top: 10px;
      }
    }
  }
}
.position-item:hover {
  box-shadow: 0 16px 32px 0 rgba(48, 55, 66, 0.15);/* 盒子悬浮时阴影 */
}

.position-item.more {
  align-items: center;
  justify-content: center;
  font-size: 15px;

  .more {
    margin-top: 8px;
    font-size: 14px;
    color: $orange;
    cursor: pointer;
  }
}

.position-item:nth-child(3n) {
  margin-right: 0;
}
</style>
